package main

import "fmt"

type Person interface {
	GetName() string
}

type Teacher struct {
	name string
}

func (p *Teacher) GetName() string {
	return "I'm a Teacher \n"
}

type Student struct {
	name string
}

func (p *Student) GetName() string {
	return "I'm a Student\n"
}


//简单工厂模式
type SimpleFactory struct {

}

func (f SimpleFactory) GetPerson(factoryType string) Person {
	if factoryType == "teacher" {
		return &Teacher{name:"Teacher Liu"}
	} else if factoryType == "student"{
		return &Student{name:"Student Tao Qi"}
	}

	return nil
}

func main() {
	factory := SimpleFactory{}
	t := factory.GetPerson("teacher")
	fmt.Println(t.GetName())

	s := factory.GetPerson("student")
	fmt.Println(s.GetName())
}
